//
//  BK_my_AndOrEditAddressCell.m
//  bestkeep
//
//  Created by bj on 2016/11/8.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BK_my_locationAddressCell.h"
#import "BKMyCommon.h"
#import "Masonry.h"

@interface BK_my_locationAddressCell ()<UITextFieldDelegate>

@end

@implementation BK_my_locationAddressCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)initlizeValue:(CellModel *)model {
    self.optionLabel.text = model.title;
    self.accessoryType = model.accessoryType;
    self.delegate = model.delegate;
    self.locationLabel.text = model.selectorString;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        _optionLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:_optionLabel];
        _optionLabel.font = [UIFont systemFontOfSize:15];
        _optionLabel.textColor = BK_MY_COLOR_07;
        [_optionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).mas_offset(15);
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.width.equalTo(@(66));
        }];
        
        self.locationLabel = [[UILabel alloc] initWithFrame:CGRectZero];
//        self.locationLabel.backgroundColor=[UIColor yellowColor];
        [self.contentView addSubview:self.locationLabel];
        self.locationLabel.font = [UIFont systemFontOfSize:15];
        self.locationLabel.userInteractionEnabled = YES;
        [self.locationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.equalTo(@(self.contentView.frame.size.height - 10));
            make.left.equalTo(_optionLabel.mas_right).mas_offset(15);
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.right.equalTo(self.contentView.mas_right).mas_offset(0);
        }];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(locationLabelClickShowPickerView:)];
        [self.locationLabel addGestureRecognizer:tap];
        
        

        //箭头
        UIImageView *rightImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"TableViewArrow"]];
        rightImageView.userInteractionEnabled=NO;
        [self.contentView addSubview:rightImageView];
        [rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.equalTo(@(15));
            make.width.equalTo(@(15));
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.right.equalTo(self.contentView.mas_right).mas_offset(-10);
        }];
        
        
    }
    return self;
}

- (void)locationLabelClickShowPickerView:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(clickLocationLabelShowPickerViewInViewController:)]) {
        [self.delegate clickLocationLabelShowPickerViewInViewController:self];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
